package com.foreveredu.erlms.persist.hibernate;

import java.util.List;

import com.foreveredu.erlms.domain.Department;
import com.foreveredu.erlms.domain.Major;
import com.foreveredu.erlms.persist.IMajorDao;

public class HibernateMajorDao extends HibernateAbstractDao<Major, Integer>
		implements IMajorDao {

	private static final long serialVersionUID = 1L;

	public HibernateMajorDao() {
		super(Major.class);
	}

	//查找某院系下的所有专业
	@SuppressWarnings("unchecked")
	@Override
	public List<Major> findMajorsOfDept(int deptId) {
		return this.getHibernateTemplate().find("from Major m where m.dept.id = ?", deptId);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Major findMajorByMajorId(String majorId) {
		List<Major> majorList = this.getHibernateTemplate().find("from Major major where major.majorId= ?", majorId);
		Major major = null;
		if (majorList != null && majorList.size() > 0) {
			major = majorList.get(0);
		}
		return major;
	}
}
